<template>
	<view class="bg-white" v-if="groupList.length">
		<view class="flex align-center justify-between">
			<u-cell-item :borderBottom="false" value="更多" hoverClass="none" @click="moreGroup" style="width:100%;">
				<view class="flex align-center" slot="title">
					<image src="/static/index/zhuangqu.png" style="width: 137rpx;height: 28rpx;" mode="aspectFill"></image>
					<!-- <image src="/static/index/index_today_group.png" style="width: 137rpx;height: 28rpx;" mode="aspectFill"></image> -->
				</view>
			</u-cell-item>
		</view>
		<view class="u-p-x-20 u-p-b-20 flex align-center justify-between" :class="{'item-flex':groupList.length<=2}" v-if="groupList.length>0">
			<view v-for="(item,index) in groupList.slice(0,3)" :key="index" @click="toGroup(item.id)">
				<index-group-today-item :item="item"></index-group-today-item>
			</view>
		</view>
	</view>
</template>

<script>
	import { GroupCenterApi ,GoodsCenterApi } from '@/api/serves.js'
	export default {
		name:"index-group-today",
		props:{
			type:{
				type: String,
				default: 'group'
			}
		},
		data() {
			return {
				groupList: [],
				formData: {//商品
                 id:-1,
                 types:'normal',
                 name:'',  // 关键字
                 is_merch:0,  // 是否自营
                 goods_min_price:'',  
                 goods_max_price:'',
				 goods_type:2,
				 page:1
               },
			}
		},
		methods: {
			// 拼团list		
			getGoodsgroup(){
			  GroupCenterApi.getGoodsGroup().then(res=>{
			    console.log('拼团',res)
			    if(res.code==1){
			      this.groupList = res.data
			    }
			  })
			},
			//  专区商品
			// 商品搜索
            getCategoryList(page) { 
              GoodsCenterApi.category_list(this.formData).then(res => {
                if (res.code == 1) {
					// console.log(res.data,"11111");
                    this.groupList = res.data.listdata
                }else {
	        		this.$u.toast(res.msg);
	        		}
              }).catch(()=>{
              	//联网失败, 结束加载
              	this.mescroll.endErr();
              })
            },
			toGroup(id) {
				if(this.type == 'goods'){
					uni.navigateTo({
						url: '/pages/goodsDetail/commonGoodsDetail/commonGoodsDetail?goods_id=' + id
					})
				}else if(this.type == 'group'){
					uni.navigateTo({
						url: '/pages/group/groupGoodsDetail/groupGoodsDetail?id=' + id
					})
				}
			},
			moreGroup() {
				if(this.type == 'goods'){
					uni.navigateTo({
						url: '/pages/goodsDetail/goodsSearch/goodSpecial'
					})
				}else if(this.type == 'group'){
					uni.navigateTo({
						url: '/pages/group/groupMore/groupMore'
					})
				}
				
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.u-cell[data-v-65423b64] {
		padding: 10rpx 20rpx;
	}
.item-flex::after{ 
	content: ''; 
	width: 230rpx; 
	border:1px solid transparent; 
}
</style>
